import type { SidebarNavItem } from '@/types/nav';

import {
  AlignCenterIcon,
  ArrowDownToLineIcon,
  ArrowRightToLineIcon,
  AtSignIcon,
  AudioLinesIcon,
  BellIcon,
  BoldIcon,
  BrickWallIcon,
  CalendarDaysIcon,
  CalendarIcon,
  CaptionsIcon,
  CheckSquareIcon,
  ChevronRightSquareIcon,
  ChevronsUpDownIcon,
  CircleGaugeIcon,
  CodeIcon,
  CodeXmlIcon,
  Columns3Icon,
  ColumnsIcon,
  CommandIcon,
  DockIcon,
  Edit3Icon,
  EllipsisIcon,
  EyeIcon,
  FileCodeIcon,
  FileIcon,
  FilesIcon,
  FileSpreadsheetIcon,
  FileTextIcon,
  FilmIcon,
  FrameIcon,
  GridIcon,
  GripVerticalIcon,
  HandIcon,
  HashIcon,
  Heading1Icon,
  HelpCircleIcon,
  HighlighterIcon,
  HistoryIcon,
  ImageIcon,
  IndentIcon,
  ItalicIcon,
  KeyboardIcon,
  LayersIcon,
  LightbulbIcon,
  LinkIcon,
  ListIcon,
  ListTodoIcon,
  LoaderCircleIcon,
  LogOutIcon,
  MenuIcon,
  MessageSquareIcon,
  MessageSquareTextIcon,
  MinusIcon,
  MonitorIcon,
  MousePointerClickIcon,
  MoveVerticalIcon,
  PaintRollerIcon,
  PaletteIcon,
  PanelTopIcon,
  PencilRulerIcon,
  PercentIcon,
  PilcrowIcon,
  PlusSquareIcon,
  ProportionsIcon,
  QuoteIcon,
  RadicalIcon,
  RectangleEllipsisIcon,
  RectangleHorizontalIcon,
  ReplaceIcon,
  SeparatorHorizontalIcon,
  ServerIcon,
  SlashIcon,
  SmileIcon,
  SparklesIcon,
  SplitSquareVerticalIcon,
  SquareDashedIcon,
  SquareMIcon,
  SquareMinusIcon,
  SquareMousePointerIcon,
  SquareStackIcon,
  StrikethroughIcon,
  SubscriptIcon,
  SuperscriptIcon,
  TableIcon,
  TableOfContentsIcon,
  TagIcon,
  TagsIcon,
  TextCursorInputIcon,
  TextSearchIcon,
  UnderlineIcon,
  UploadIcon,
  UserIcon,
  UsersIcon,
} from 'lucide-react';

export const DocIcons = {
  ai: SparklesIcon,
  'ai-menu': SparklesIcon,
  'ai-node': SparklesIcon,
  'ai-toolbar-button': SparklesIcon,
  'alert-dialog': SquareStackIcon,
  'align-toolbar-button': AlignCenterIcon,
  autoformat: PercentIcon,
  avatar: UserIcon,
  'basic-blocks': Heading1Icon,
  'basic-editor-default': KeyboardIcon,
  'basic-editor-handler': HandIcon,
  'basic-editor-styling': PaletteIcon,
  'basic-editor-value': FilesIcon,
  'basic-marks': BoldIcon,
  'basic-nodes': Heading1Icon,
  'basic-plugins-components': MonitorIcon,
  'basic-plugins-default': LayersIcon,
  'block-context-menu': MenuIcon,
  'block-list': ListTodoIcon,
  'block-menu': MenuIcon,
  'block-selection': SquareMousePointerIcon,
  blockquote: QuoteIcon,
  'blockquote-node': QuoteIcon,
  bold: BoldIcon,
  button: SquareMinusIcon,
  calendar: CalendarDaysIcon,
  callout: LightbulbIcon,
  caption: CaptionsIcon,
  checkbox: CheckSquareIcon,
  code: CodeIcon,
  'code-block': FileCodeIcon,
  'code-block-node': FileCodeIcon,
  'code-node': CodeIcon,
  collaboration: UsersIcon,
  'collaboration-demo': UsersIcon,
  column: Columns3Icon,
  'column-node': ColumnsIcon,
  combobox: SlashIcon,
  command: CommandIcon,
  comment: MessageSquareTextIcon,
  'comment-node': MessageSquareTextIcon,
  'comment-toolbar-button': MessageSquareTextIcon,
  'context-menu': MousePointerClickIcon,
  copilot: ArrowRightToLineIcon,
  csv: FileSpreadsheetIcon,
  'cursor-overlay': TextCursorInputIcon,
  date: CalendarIcon,
  'date-node': CalendarIcon,
  default: CodeXmlIcon,
  dialog: SquareStackIcon,
  dnd: GripVerticalIcon,
  docx: FileTextIcon,
  draggable: GripVerticalIcon,
  'dropdown-menu': ChevronsUpDownIcon,
  'editable-voids': Edit3Icon,
  editor: FileTextIcon,
  emoji: SmileIcon,
  'emoji-dropdown-menu': SmileIcon,
  'emoji-node': SmileIcon,
  equation: RadicalIcon,
  excalidraw: PencilRulerIcon,
  'excalidraw-node': PencilRulerIcon,
  'exit-break': LogOutIcon,
  'find-replace': TextSearchIcon,
  'fixed-toolbar': PanelTopIcon,
  'fixed-toolbar-buttons': PanelTopIcon,
  'floating-toolbar': RectangleEllipsisIcon,
  'floating-toolbar-buttons': RectangleEllipsisIcon,
  font: PaintRollerIcon,
  'font-color-toolbar-button': PaintRollerIcon,
  'forced-layout': BrickWallIcon,
  'ghost-text': ArrowRightToLineIcon,
  'ghost-text-node': ArrowRightToLineIcon,
  heading: Heading1Icon,
  'heading-node': Heading1Icon,
  highlight: HighlighterIcon,
  'highlight-node': HighlighterIcon,
  'history-toolbar-button': HistoryIcon,
  'horizontal-rule': MinusIcon,
  'hr-node': MinusIcon,
  html: FileCodeIcon,
  'hundreds-blocks': CircleGaugeIcon,
  'hundreds-editors': CircleGaugeIcon,
  iframe: FrameIcon,
  indent: IndentIcon,
  'indent-toolbar-button': ListIcon,
  'inline-combobox': SlashIcon,
  input: RectangleHorizontalIcon,
  'insert-toolbar-button': PlusSquareIcon,
  italic: ItalicIcon,
  kbd: KeyboardIcon,
  'kbd-node': KeyboardIcon,
  'line-height': MoveVerticalIcon,
  'line-height-toolbar-button': MoveVerticalIcon,
  link: LinkIcon,
  'link-node': LinkIcon,
  'link-toolbar': LinkIcon,
  'link-toolbar-button': LinkIcon,
  list: ListIcon,
  'list-classic': ListIcon,
  'list-classic-node': ListIcon,
  'list-classic-toolbar-button': ListIcon,
  'list-toolbar-button': ListIcon,
  'mark-toolbar-button': BoldIcon,
  markdown: SquareMIcon,
  'markdown-streaming': SquareMIcon,
  'markdown-to-slate': SquareMIcon,
  media: ImageIcon,
  'media-audio-node': AudioLinesIcon,
  'media-embed-node': DockIcon,
  'media-file-node': FileIcon,
  'media-image-node': ImageIcon,
  'media-placeholder-node': SquareDashedIcon,
  'media-preview-dialog': ImageIcon,
  'media-toolbar': ImageIcon,
  'media-toolbar-button': ImageIcon,
  'media-upload-toast': BellIcon,
  'media-video-node': FilmIcon,
  mention: AtSignIcon,
  'mention-node': AtSignIcon,
  'mode-toolbar-button': EyeIcon,
  'more-toolbar-button': EllipsisIcon,
  'multi-select': TagsIcon,
  'multiple-editors': SplitSquareVerticalIcon,
  'node-id': HashIcon,
  'paragraph-node': PilcrowIcon,
  playground: FileCodeIcon,
  popover: MessageSquareIcon,
  'preview-markdown': SquareMIcon,
  resizable: ProportionsIcon,
  'search-highlight-node': HighlighterIcon,
  select: KeyboardIcon,
  'select-editor': TagsIcon,
  separator: SeparatorHorizontalIcon,
  'server-side': ServerIcon,
  'single-block': RectangleHorizontalIcon,
  'slash-command': SlashIcon,
  'slash-node': SlashIcon,
  spinner: LoaderCircleIcon,
  strikethrough: StrikethroughIcon,
  subscript: SubscriptIcon,
  superscript: SuperscriptIcon,
  tabbable: ArrowRightToLineIcon,
  table: TableIcon,
  'table-node': GridIcon,
  'table-toolbar-button': TableIcon,
  'tag-node': TagIcon,
  'text-align': AlignCenterIcon,
  textAlign: AlignCenterIcon,
  toc: TableOfContentsIcon,
  'toc-node': TableOfContentsIcon,
  toggle: ChevronRightSquareIcon,
  'toggle-node': ChevronRightSquareIcon,
  'toggle-toolbar-button': ChevronRightSquareIcon,
  toolbar: PanelTopIcon,
  tooltip: HelpCircleIcon,
  'trailing-block': ArrowDownToLineIcon,
  'turn-into-toolbar-button': ReplaceIcon,
  underline: UnderlineIcon,
  upload: UploadIcon,
  'version-history': HistoryIcon,
};

export const getDocIcon = (item: SidebarNavItem, category?: string) => {
  if (category === 'guide') return null;

  const icon = item.icon ?? item.href?.split('/').pop();

  return (DocIcons as any)[icon!] ?? (category === 'api' ? CodeXmlIcon : null);
};
